home *** CD-ROM | disk | FTP | other *** search
/ Czech Logic, Card & Gambling Games / Logické hry.iso / hry / Fish Fillets / script / creatures / code.lua next >
Encoding:
Text File  |  2005-07-16  |  26.2 KB  |  740 lines

  1.  
  2. local function isOneOf(models, x, y)
  3.     for key, model in pairs(models) do
  4.         if modelEquals(model, x, y) then
  5.             return true
  6.         end
  7.     end
  8.     return false
  9. end
  10.  
  11. -- -----------------------------------------------------------------
  12. -- Init
  13. -- -----------------------------------------------------------------
  14. local function prog_init()
  15.     initModels()
  16.     local pokus = getRestartCount()
  17.     local windflowers = {}
  18.     table.insert(windflowers, sas1)
  19.     table.insert(windflowers, sas2)
  20.     table.insert(windflowers, sas3)
  21.     table.insert(windflowers, sas4)
  22.     table.insert(windflowers, sas5)
  23.     table.insert(windflowers, sas6)
  24.  
  25.     -- -------------------------------------------------------------
  26.     local function prog_init_room()
  27.         local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
  28.  
  29.         room.quvod = random(20) + 20
  30.         room.qhlaska = random(100) + 100
  31.         room.pouzito = {}
  32.         room.vydrz = random(2) + 2
  33.         room.komentovaly = 0
  34.         room.kreseni = 0
  35.  
  36.         return function()
  37.             if isReady(small) and isReady(big) and no_dialog() and (balalajka.cinnost == 0 or balalajka.cinnost > 70) then
  38.                 if room.quvod > 0 then
  39.                     room.quvod = room.quvod - 1
  40.                 end
  41.                 if balalajka.hrala > 0 then
  42.                     room.quvod = -1
  43.                 end
  44.                 if room.qhlaska > 0 then
  45.                     room.qhlaska = room.qhlaska - 1
  46.                 end
  47.                 if room.komentovaly < balalajka.hrala then
  48.                     --TODO: getRestartCount cannot be changed
  49.                     if pokus < 1000 then
  50.                         pokus = pokus + 1000
  51.                     end
  52.                     room.komentovaly = balalajka.hrala
  53.                     if room.komentovaly <= room.vydrz then
  54.                         switch(random(4)){
  55.                             [2] = function()
  56.                                 addv(0, "kor-v-odvaz")
  57.                             end,
  58.                             [3] = function()
  59.                                 addm(6, "kor-m-vsimlsis")
  60.                                 addv(2, "kor-v-avidelas")
  61.                                 addm(4, "kor-m-tovis")
  62.                             end,
  63.                             default = function()
  64.                                 if random(2) == 1 then
  65.                                     addv(6, "kor-v-juchacka")
  66.                                 else
  67.                                     addv(6, "kor-v-vali")
  68.                                 end
  69.                                 switch(random(3)){
  70.                                     [0] = function()
  71.                                         addm(3, "kor-m-hraje")
  72.                                     end,
  73.                                     [1] = function()
  74.                                         addm(3, "kor-m-nachob")
  75.                                     end,
  76.                                 }
  77.                             end,
  78.                         }
  79.                     else
  80.                         pom1 = random(6)
  81.                         for pom2 = 1, 2 do
  82.                             if pom2 == 1 and isIn(pom1, {0, 1, 4}) and random(3) == 0 or pom2 == 2 and pom1 == 5 then
  83.                                 switch(random(2)){
  84.                                     [0] = function()
  85.                                         addm(5, "kor-m-jinou")
  86.                                     end,
  87.                                     [1] = function()
  88.                                         addm(5, "kor-m-neprehani")
  89.                                     end,
  90.                                 }
  91.                             elseif pom2 == 1 and pom1 <= 1 then
  92.                                 addm(5, "kor-m-lezekrkem")
  93.                             end
  94.                             if pom2 == 1 and isIn(pom1, {2, 3, 5}) or pom2 == 2 and pom1 == 4 then
  95.                                 switch(random(2)){
  96.                                     [0] = function()
  97.                                         addv(5, "kor-v-lezekrkem")
  98.                                     end,
  99.                                     [1] = function()
  100.                                         addv(5, "kor-v-kostice")
  101.                                     end,
  102.                                 }
  103.                             end
  104.                         end
  105.                     end
  106.                 elseif room.kreseni == 0 and big.X >= 30 and big.Y == 5 and elko.X == 30 then
  107.                     room.kreseni = room.kreseni + 1
  108.                     addv(5, "kor-v-odsud")
  109.                     addm(8, "kor-m-budesmuset")
  110.                 elseif room.kreseni == 1 and isWater(10, 6) and isWater(23, 6) then
  111.                     room.kreseni = room.kreseni + 1
  112.                 elseif room.kreseni == 2 and (isOneOf(windflowers, 10, 6) or isOneOf(windflowers, 23, 6)) then
  113.                     room.kreseni = room.kreseni + 1
  114.                     addm(10, "kor-m-neniono")
  115.                     addm(20, "kor-m-tudiru")
  116.                 elseif room.qhlaska == 0 then
  117.                     room.qhlaska = random(600) + 200
  118.                     pom1 = random(6)
  119.                     if not room.pouzito[pom1] then
  120.                         switch(pom1){
  121.                             [0] = function()
  122.                                 addm(10, "kor-m-dusi")
  123.                             end,
  124.                             [1] = function()
  125.                                 addm(10, "kor-m-pocit")
  126.                             end,
  127.                             [2] = function()
  128.                                 addm(10, "kor-m-bizarni")
  129.                             end,
  130.                             [3] = function()
  131.                                 addv(10, "kor-v-bermudy")
  132.                             end,
  133.                             [4] = function()
  134.                                 addv(10, "kor-v-inteligentni")
  135.                             end,
  136.                             [5] = function()
  137.                                 addv(10, "kor-v-jedovate")
  138.                             end,
  139.                         }
  140.                     end
  141.                     room.pouzito[pom1] = true
  142.                 elseif room.quvod == 0 then
  143.                     --TODO: getRestartCount cannot be changed
  144.                     if 1 <= pokus and pokus <= 1000 then
  145.                         room.quvod = random(2) + 1
  146.                     elseif 1001 <= pokus and pokus <= 2000 then
  147.                         room.quvod = 3
  148.                         pokus = pokus + 1000
  149.                     else
  150.                         room.quvod = random(4)
  151.                     end
  152.                     if room.quvod == 0 or room.quvod == 1 then
  153.                         addv(10, "kor-v-podivej")
  154.                         addm(2, "kor-m-vzdyt")
  155.                         addv(6, "kor-v-treba")
  156.                     elseif room.quvod == 2 or room.quvod == 3 then
  157.                         addm(10, "kor-m-podivej")
  158.                         addv(5, "kor-v-spitu")
  159.                         if random(100) < 40 then
  160.                             addm(2, "kor-m-avlada")
  161.                         end
  162.                         addv(10, "kor-v-nicje")
  163.                         if room.quvod == 3 then
  164.                             addm(5, "kor-m-pokud")
  165.                         end
  166.                     end
  167.                     room.quvod = -1
  168.                 end
  169.             end
  170.         end
  171.     end
  172.  
  173.     -- -------------------------------------------------------------
  174.     local function prog_init_krab1()
  175.         local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
  176.  
  177.         krab1.krabfaze = 1
  178.         krab1.cekat = 0
  179.  
  180.         return function()
  181.             if room:isTalking() then
  182.                 switch(math.mod(game_getCycles(), 4)){
  183.                     [0] = function()
  184.                         krab1.krabfaze = 7
  185.                     end,
  186.                     [1] = function()
  187.                         krab1.krabfaze = 7
  188.                     end,
  189.                     default = function()
  190.                         krab1.krabfaze = 9
  191.                     end,
  192.                 }
  193.             elseif krab1.krabfaze <= 2 then
  194.                 krab1.krabfaze = 1
  195.             else
  196.                 krab1.krabfaze = 2
  197.             end
  198.             if krab1.krabfaze == 2 then
  199.                 krab1.cekat = random(70) + 30
  200.             end
  201.             if krab1.krabfaze <= 2 then
  202.                 if krab1.cekat == 0 then
  203.                     krab1.afaze = 1
  204.                 else
  205.                     krab1.afaze = 0
  206.                     krab1.cekat = krab1.cekat - 1
  207.                 end
  208.             elseif not isWater(krab1.X, krab1.Y + 1) and not isWater(krab1.X + 1, krab1.Y + 1) then
  209.                 krab1.afaze = krab1.krabfaze
  210.             elseif random(100) < 50 then
  211.                 krab1.afaze = random(4) + 2
  212.             end
  213.             krab1:updateAnim()
  214.         end
  215.     end
  216.  
  217.     -- -------------------------------------------------------------
  218.     local function prog_init_balalajka()
  219.         local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
  220.  
  221.         balalajka.cinnost = 0
  222.         balalajka.hrala = 0
  223.         balalajka.tcatcat = random(15) + 10
  224.  
  225.         return function()
  226.             if balalajka.dir ~= dir_no and balalajka.cinnost == 0 then
  227.                 balalajka.cinnost = balalajka.cinnost + 1
  228.             end
  229.             switch(balalajka.cinnost){
  230.                 [0] = function()
  231.                     local cycle = math.mod(game_getCycles(), 18)
  232.                     switch(cycle){
  233.                         [0] = function()
  234.                             if balalajka.tcatcat == 0 then
  235.                                 balalajka:talk("kor-chob-tca", VOLUME_FULL)
  236.                                 balalajka.tcatcat = random(15) + 10
  237.                             else
  238.                                 balalajka:talk("kor-chob-psi", VOLUME_FULL)
  239.                                 balalajka.tcatcat = balalajka.tcatcat - 1
  240.                             end
  241.                         end,
  242.                         [11] = function()
  243.                             balalajka:talk("kor-chob-chro", VOLUME_FULL)
  244.                         end,
  245.                         default = function()
  246.                             if 1 <= cycle and cycle <= 10 then
  247.                                 balalajka.afaze = 0
  248.                             else
  249.                                 balalajka.afaze = 1
  250.                             end
  251.                         end,
  252.                     }
  253.                 end,
  254.                 [1] = function()
  255.                     balalajka.hrala = balalajka.hrala + 1
  256.                     game_killPlan()
  257.                     balalajka.afaze = 2
  258.                     balalajka:killSound()
  259.                 end,
  260.                 [6] = function()
  261.                     balalajka.afaze = 3
  262.                 end,
  263.                 [10] = function()
  264.                     balalajka.afaze = 4
  265.                 end,
  266.                 [13] = function()
  267.                     balalajka.afaze = 3
  268.                 end,
  269.                 [15] = function()
  270.                     balalajka.afaze = 4
  271.                 end,
  272.                 [17] = function()
  273.                     balalajka.afaze = 5
  274.                 end,
  275.                 [19] = function()
  276.                     room:talk("kor-room-music", VOLUME_LOW)
  277.                 end,
  278.                 [83] = function()
  279.                     balalajka.afaze = 5
  280.                 end,
  281.                 [90] = function()
  282.                     balalajka.cinnost = 0
  283.                 end,
  284.                 default = function()
  285.                     if isIn(balalajka.cinnost, {21, 23, 25, 27}) then
  286.                         balalajka.afaze = 6
  287.                     elseif isIn(balalajka.cinnost, {22, 24, 26, 28}) then
  288.                         if random(100) < 10 then
  289.                             balalajka.afaze = 7
  290.                         else
  291.                             balalajka.afaze = 8
  292.                         end
  293.                     elseif isIn(balalajka.cinnost, {29, 31, 33, 35}) then
  294.                         balalajka.afaze = 9
  295.                     elseif isIn(balalajka.cinnost, {30, 32, 34, 36}) then
  296.                         balalajka.afaze = 10
  297.                     end
  298.                 end,
  299.             }
  300.             if balalajka.cinnost > 20 and balalajka.cinnost < 80 and not room:isTalking() then
  301.                 balalajka.cinnost = 80
  302.             elseif balalajka.cinnost == 36 then
  303.                 balalajka.cinnost = 21
  304.             elseif balalajka.cinnost > 0 then
  305.                 balalajka.cinnost = balalajka.cinnost + 1
  306.             end
  307.             balalajka:updateAnim()
  308.         end
  309.     end
  310.  
  311.     -- -------------------------------------------------------------
  312.     local function prog_init_sas1()
  313.         local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
  314.  
  315.         sas1.sasfaze = -1
  316.         sas1.kvet = random(2) * 2 + 1
  317.         sas1.noha = random(2)
  318.  
  319.         return function()
  320.             if room:isTalking() then
  321.                 local cycle = math.mod(game_getCycles(), 8)
  322.                 if isIn(cycle, {0, 1, 2, 3}) then
  323.                     pom1 = 0
  324.                 else
  325.                     pom1 = 1
  326.                 end
  327.                 if isIn(cycle, {0, 3, 4, 7}) then
  328.                     pom2 = 2
  329.                 else
  330.                     pom2 = 1
  331.                 end
  332.                 sas1.sasfaze = pom1 * 4 + pom2
  333.             else
  334.                 sas1.sasfaze = -1
  335.             end
  336.             if isWater(sas1.X + 1, sas1.Y - 1) or modelEquals(room, sas1.X + 1, sas1.Y - 1) then
  337.                 if sas1.sasfaze >= 0 then
  338.                     sas1.afaze = sas1.sasfaze
  339.                 else
  340.                     if math.mod(game_getCycles(), 3) == 0 and random(100) < 50 then
  341.                         sas1.kvet = random(2) * 2 + 1
  342.                     end
  343.                     if math.mod(game_getCycles(), 4) == 0 and random(100) < 30 then
  344.                         sas1.noha = random(2)
  345.                     end
  346.                     sas1.afaze = sas1.noha * 4 + sas1.kvet
  347.                 end
  348.             else
  349.                 sas1.afaze = 0
  350.             end
  351.             sas1:updateAnim()
  352.         end
  353.     end
  354.  
  355.     -- -------------------------------------------------------------
  356.     local function prog_init_sas2()
  357.         local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
  358.  
  359.         sas2.kvet = random(2) * 2 + 1
  360.         sas2.noha = random(2)
  361.  
  362.         return function()
  363.             if isWater(sas2.X + 1, sas2.Y - 1) or modelEquals(room, sas2.X + 1, sas2.Y - 1) then
  364.                 if sas1.sasfaze >= 0 then
  365.                     sas2.afaze = sas1.sasfaze
  366.                 else
  367.                     if math.mod(game_getCycles(), 3) == 0 and random(100) < 50 then
  368.                         sas2.kvet = random(2) * 2 + 1
  369.                     end
  370.                     if math.mod(game_getCycles(), 4) == 0 and random(100) < 30 then
  371.                         sas2.noha = random(2)
  372.                     end
  373.                     sas2.afaze = sas2.noha * 4 + sas2.kvet
  374.                 end
  375.             else
  376.                 sas2.afaze = 0
  377.             end
  378.             sas2:updateAnim()
  379.         end
  380.     end
  381.  
  382.     -- -------------------------------------------------------------
  383.     local function prog_init_sas3()
  384.         local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
  385.  
  386.         sas3.kvet = random(2) * 2 + 1
  387.         sas3.noha = random(2)
  388.  
  389.         return function()
  390.             if isWater(sas3.X + 1, sas3.Y - 1) or modelEquals(room, sas3.X + 1, sas3.Y - 1) then
  391.                 if sas1.sasfaze >= 0 then
  392.                     sas3.afaze = sas1.sasfaze
  393.                 else
  394.                     if math.mod(game_getCycles(), 3) == 0 and random(100) < 50 then
  395.                         sas3.kvet = random(2) * 2 + 1
  396.                     end
  397.                     if math.mod(game_getCycles(), 4) == 0 and random(100) < 30 then
  398.                         sas3.noha = random(2)
  399.                     end
  400.                     sas3.afaze = sas3.noha * 4 + sas3.kvet
  401.                 end
  402.             else
  403.                 sas3.afaze = 0
  404.             end
  405.             sas3:updateAnim()
  406.         end
  407.     end
  408.  
  409.     -- -------------------------------------------------------------
  410.     local function prog_init_sas4()
  411.         local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
  412.  
  413.         sas4.kvet = random(2) * 2 + 1
  414.         sas4.noha = random(2)
  415.  
  416.         return function()
  417.             if isWater(sas4.X + 1, sas4.Y - 1) or modelEquals(room, sas4.X + 1, sas4.Y - 1) then
  418.                 if sas1.sasfaze >= 0 then
  419.                     sas4.afaze = sas1.sasfaze
  420.                 else
  421.                     if math.mod(game_getCycles(), 3) == 0 and random(100) < 50 then
  422.                         sas4.kvet = random(2) * 2 + 1
  423.                     end
  424.                     if math.mod(game_getCycles(), 4) == 0 and random(100) < 30 then
  425.                         sas4.noha = random(2)
  426.                     end
  427.                     sas4.afaze = sas4.noha * 4 + sas4.kvet
  428.                 end
  429.             else
  430.                 sas4.afaze = 0
  431.             end
  432.             sas4:updateAnim()
  433.         end
  434.     end
  435.  
  436.     -- -------------------------------------------------------------
  437.     local function prog_init_sas5()
  438.         local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
  439.  
  440.         sas5.kvet = random(2) * 2 + 1
  441.         sas5.noha = random(2)
  442.  
  443.         return function()
  444.             if isWater(sas5.X + 1, sas5.Y - 1) or modelEquals(room, sas5.X + 1, sas5.Y - 1) then
  445.                 if sas1.sasfaze >= 0 then
  446.                     sas5.afaze = sas1.sasfaze
  447.                 else
  448.                     if math.mod(game_getCycles(), 3) == 0 and random(100) < 50 then
  449.                         sas5.kvet = random(2) * 2 + 1
  450.                     end
  451.                     if math.mod(game_getCycles(), 4) == 0 and random(100) < 30 then
  452.                         sas5.noha = random(2)
  453.                     end
  454.                     sas5.afaze = sas5.noha * 4 + sas5.kvet
  455.                 end
  456.             else
  457.                 sas5.afaze = 0
  458.             end
  459.             sas5:updateAnim()
  460.         end
  461.     end
  462.  
  463.     -- -------------------------------------------------------------
  464.     local function prog_init_sas6()
  465.         local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
  466.  
  467.         sas6.kvet = random(2) * 2 + 1
  468.         sas6.noha = random(2)
  469.  
  470.         return function()
  471.             if isWater(sas6.X + 1, sas6.Y - 1) or modelEquals(room, sas6.X + 1, sas6.Y - 1) then
  472.                 if sas1.sasfaze >= 0 then
  473.                     sas6.afaze = sas1.sasfaze
  474.                 else
  475.                     if math.mod(game_getCycles(), 3) == 0 and random(100) < 50 then
  476.                         sas6.kvet = random(2) * 2 + 1
  477.                     end
  478.                     if math.mod(game_getCycles(), 4) == 0 and random(100) < 30 then
  479.                         sas6.noha = random(2)
  480.                     end
  481.                     sas6.afaze = sas6.noha * 4 + sas6.kvet
  482.                 end
  483.             else
  484.                 sas6.afaze = 0
  485.             end
  486.             sas6:updateAnim()
  487.         end
  488.     end
  489.  
  490.     -- -------------------------------------------------------------
  491.     local function prog_init_krab2()
  492.         local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
  493.  
  494.         krab2.cekat = 0
  495.  
  496.         return function()
  497.             if krab1.krabfaze == 2 then
  498.                 krab2.cekat = random(70) + 30
  499.             end
  500.             if krab1.krabfaze <= 2 then
  501.                 if krab2.cekat == 0 then
  502.                     krab2.afaze = 1
  503.                 else
  504.                     krab2.afaze = 0
  505.                     krab2.cekat = krab2.cekat - 1
  506.                 end
  507.             elseif not isWater(krab2.X, krab2.Y + 1) and not isWater(krab2.X + 1, krab2.Y + 1) then
  508.                 krab2.afaze = krab1.krabfaze
  509.             elseif random(100) < 50 then
  510.                 krab2.afaze = random(4) + 2
  511.             end
  512.             krab2:updateAnim()
  513.         end
  514.     end
  515.  
  516.     -- -------------------------------------------------------------
  517.     local function prog_init_krab3()
  518.         local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
  519.  
  520.         krab3.cekat = 0
  521.  
  522.         return function()
  523.             if krab1.krabfaze == 2 then
  524.                 krab3.cekat = random(70) + 30
  525.             end
  526.             if krab1.krabfaze <= 2 then
  527.                 if krab3.cekat == 0 then
  528.                     krab3.afaze = 1
  529.                 else
  530.                     krab3.afaze = 0
  531.                     krab3.cekat = krab3.cekat - 1
  532.                 end
  533.             elseif not isWater(krab3.X, krab3.Y + 1) and not isWater(krab3.X + 1, krab3.Y + 1) then
  534.                 krab3.afaze = krab1.krabfaze
  535.             elseif random(100) < 50 then
  536.                 krab3.afaze = random(4) + 2
  537.             end
  538.             krab3:updateAnim()
  539.         end
  540.     end
  541.  
  542.     -- -------------------------------------------------------------
  543.     local function prog_init_krab4()
  544.         local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
  545.  
  546.         krab4.cekat = 0
  547.  
  548.         return function()
  549.             if krab1.krabfaze == 2 then
  550.                 krab4.cekat = random(70) + 30
  551.             end
  552.             if krab1.krabfaze <= 2 then
  553.                 if krab4.cekat == 0 then
  554.                     krab4.afaze = 1
  555.                 else
  556.                     krab4.afaze = 0
  557.                     krab4.cekat = krab4.cekat - 1
  558.                 end
  559.             elseif not isWater(krab4.X, krab4.Y + 1) and not isWater(krab4.X + 1, krab4.Y + 1) then
  560.                 krab4.afaze = krab1.krabfaze
  561.             elseif random(100) < 50 then
  562.                 krab4.afaze = random(4) + 2
  563.             end
  564.             krab4:updateAnim()
  565.         end
  566.     end
  567.  
  568.     -- -------------------------------------------------------------
  569.     local function prog_init_krab5()
  570.         local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
  571.  
  572.         krab5.cekat = 0
  573.  
  574.         return function()
  575.             if krab1.krabfaze == 2 then
  576.                 krab5.cekat = random(70) + 30
  577.             end
  578.             if krab1.krabfaze <= 2 then
  579.                 if krab5.cekat == 0 then
  580.                     krab5.afaze = 1
  581.                 else
  582.                     krab5.afaze = 0
  583.                     krab5.cekat = krab5.cekat - 1
  584.                 end
  585.             elseif not isWater(krab5.X, krab5.Y + 1) and not isWater(krab5.X + 1, krab5.Y + 1) then
  586.                 krab5.afaze = krab1.krabfaze
  587.             elseif random(100) < 50 then
  588.                 krab5.afaze = random(4) + 2
  589.             end
  590.             krab5:updateAnim()
  591.         end
  592.     end
  593.  
  594.     -- -------------------------------------------------------------
  595.     local function prog_init_krab6()
  596.         local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
  597.  
  598.         krab6.cekat = 0
  599.  
  600.         return function()
  601.             if krab1.krabfaze == 2 then
  602.                 krab6.cekat = random(70) + 30
  603.             end
  604.             if krab1.krabfaze <= 2 then
  605.                 if krab6.cekat == 0 then
  606.                     krab6.afaze = 1
  607.                 else
  608.                     krab6.afaze = 0
  609.                     krab6.cekat = krab6.cekat - 1
  610.                 end
  611.             elseif not isWater(krab6.X, krab6.Y + 1) and not isWater(krab6.X + 1, krab6.Y + 1) then
  612.                 krab6.afaze = krab1.krabfaze
  613.             elseif random(100) < 50 then
  614.                 krab6.afaze = random(4) + 2
  615.             end
  616.             krab6:updateAnim()
  617.         end
  618.     end
  619.  
  620.     -- -------------------------------------------------------------
  621.     local function prog_init_sepie()
  622.         local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
  623.  
  624.         sepie.mrk = 0
  625.         sepie.nohy = 0
  626.  
  627.         return function()
  628.             pomb1 = sepie.dir == dir_down
  629.             pomb2 = isWater(sepie.X, sepie.Y + 1) and isWater(sepie.X + 1, sepie.Y + 1) and not isWater(sepie.X + 2, sepie.Y + 3)
  630.             if sepie.mrk > 0 then
  631.                 sepie.mrk = sepie.mrk - 1
  632.             elseif random(100) < 15 then
  633.                 sepie.mrk = random(3) + 2
  634.             end
  635.             if pomb1 or not pomb2 then
  636.                 if odd(game_getCycles()) then
  637.                     sepie.nohy = math.mod(sepie.nohy + 2 + random(2) * 2, 3)
  638.                 end
  639.                 sepie.afaze = sepie.nohy
  640.                 if pomb1 then
  641.                     sepie.afaze = sepie.nohy + 3
  642.                 elseif sepie.mrk > 0 then
  643.                     sepie.afaze = sepie.nohy + 6
  644.                 else
  645.                     sepie.afaze = sepie.nohy
  646.                 end
  647.             else
  648.                 if sepie.dir == dir_left or sepie.dir == dir_right then
  649.                     sepie.nohy = math.mod(sepie.nohy + 1, 2)
  650.                 else
  651.                     sepie.nohy = 0
  652.                 end
  653.                 if sepie.mrk > 0 then
  654.                     sepie.afaze = 2 * sepie.nohy + 10
  655.                 else
  656.                     sepie.afaze = 2 * sepie.nohy + 9
  657.                 end
  658.             end
  659.             sepie:updateAnim()
  660.         end
  661.     end
  662.  
  663.     -- --------------------
  664.     local update_table = {}
  665.     local subinit
  666.     subinit = prog_init_room()
  667.     if subinit then
  668.         table.insert(update_table, subinit)
  669.     end
  670.     subinit = prog_init_krab1()
  671.     if subinit then
  672.         table.insert(update_table, subinit)
  673.     end
  674.     subinit = prog_init_balalajka()
  675.     if subinit then
  676.         table.insert(update_table, subinit)
  677.     end
  678.     subinit = prog_init_sas1()
  679.     if subinit then
  680.         table.insert(update_table, subinit)
  681.     end
  682.     subinit = prog_init_sas2()
  683.     if subinit then
  684.         table.insert(update_table, subinit)
  685.     end
  686.     subinit = prog_init_sas3()
  687.     if subinit then
  688.         table.insert(update_table, subinit)
  689.     end
  690.     subinit = prog_init_sas4()
  691.     if subinit then
  692.         table.insert(update_table, subinit)
  693.     end
  694.     subinit = prog_init_sas5()
  695.     if subinit then
  696.         table.insert(update_table, subinit)
  697.     end
  698.     subinit = prog_init_sas6()
  699.     if subinit then
  700.         table.insert(update_table, subinit)
  701.     end
  702.     subinit = prog_init_krab2()
  703.     if subinit then
  704.         table.insert(update_table, subinit)
  705.     end
  706.     subinit = prog_init_krab3()
  707.     if subinit then
  708.         table.insert(update_table, subinit)
  709.     end
  710.     subinit = prog_init_krab4()
  711.     if subinit then
  712.         table.insert(update_table, subinit)
  713.     end
  714.     subinit = prog_init_krab5()
  715.     if subinit then
  716.         table.insert(update_table, subinit)
  717.     end
  718.     subinit = prog_init_krab6()
  719.     if subinit then
  720.         table.insert(update_table, subinit)
  721.     end
  722.     subinit = prog_init_sepie()
  723.     if subinit then
  724.         table.insert(update_table, subinit)
  725.     end
  726.     return update_table
  727. end
  728. local update_table = prog_init()
  729.  
  730.  
  731. -- -----------------------------------------------------------------
  732. -- Update
  733. -- -----------------------------------------------------------------
  734. function prog_update()
  735.     for key, subupdate in pairs(update_table) do
  736.         subupdate()
  737.     end
  738. end
  739.  
  740.